<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
use App\Services\Permission\LogsService;

class LogRequest implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $logData;

    /**
     * Create a new job instance.
     *
     * @param array $logData
     * @return void
     */
    public function __construct(array $logData)
    {
        $this->logData = $logData;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $logsService = app(LogsService::class);
        $logsService->create($this->logData);
        // DB::table('logs')->insert([
        //     'admin_id'   => $this->logData['admin_id'],
        //     'admin_name' => $this->logData['admin_name'],
        //     'title'      => $this->logData['title'],
        //     'url'        => $this->logData['url'],
        //     'ip'         => $this->logData['ip'],
        //     'browser'    => $this->logData['browser'],
        //     'method'     => $this->logData['method'],
        //     'params'     => $this->logData['params'],
        //     'created_at' => now(),
        // ]);
    }
}